package com.lims.dao.common.impl;

import java.util.List;


import com.lims.dao.base.BaseDAOImpl;
import com.lims.dao.common.ITaskDAO;
import com.lims.po.common.Task;

public class TaskDAOImpl extends BaseDAOImpl<Task> implements ITaskDAO {
	private static final String className=TaskDAOImpl.class.toString();
	public List<Task> selectAll(){
		String hql="from Task order by pid ";
		return super.ExecuteQuery(hql, className+"-->selectAll()");
	}
	public List<Task> selectAllByDepartmentId(int departmentId){
		String hql="from Task where department.pid="+departmentId+" order by pid ";
		return super.ExecuteQuery(hql, className+"-->selectAllByDepartmentId(int departmentId)");
	}
	
	public boolean saveTask(Task task){
		return super.saveObject(task, className+"-->saveTask(Task Task)")>0?true:false;
	}
	public boolean updateTask(Task task){
		return super.updateObject(task, className+"-->updateTask(Task Task)");
	}
	public boolean deleteTask(Task task){
		return super.deleteObject(task, className+"-->deleteTask(Task Task)");
	}
	public boolean deleteTaskById(int pid){
		String hql="delete from Task where pid="+pid;
		return super.ExecuteNonQuery(hql, className+"-->deleteTaskById(int pid)");
	}
	
	public Task selectTaskById(int pid) {
		return super.selectById(pid, className+"-->selectTaskById(int pid)");
	}
	public boolean selectTaskBySampleTitle(String task) {
		String hql="from Task where TaskName='"+task+"'";
		return super.ExecuteQuery(hql, className+"-->selectTaskByTaskName(String TaskName)").size()==0?false:true;
	
	}
}
